<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <link rel="stylesheet" href="https://cache.amap.com/lbs/static/main1119.css"/>
    <script type="text/javascript" src="https://webapi.amap.com/maps?v=1.4.10&key=62aefed2dd623a0f5042245bf44f362f&plugin=AMap.Autocomplete,AMap.PlaceSearch"></script>
    <script type="text/javascript" src="https://cache.amap.com/lbs/static/addToolbar.js"></script>
    <style>
        #container {width:600px; height: 400px; }
        div{
            border: 1px red solid;
        }

    </style>
    <script src="../lib/js/jquery-3.1.1.min.js"></script>
    <script src="../lib/js/uitl.js"></script>
</head>
<body>
<div id="container"></div>
<div id="myPageTop">
    <table>
        <tr>
            <td>
                <label>请输入关键字：</label>
            </td>
        </tr>
        <tr>
            <td>
                <input id="tipinput"/>
            </td>
        </tr>
    </table>
</div>

<div style="height: 400px;width: 200px;overflow-y: auto">
    <div style="height: 800px;width: 180px"> </div>
</div>
</body>
<script type="text/javascript">
    /*地图点击*/
    $(function () {
        bind()
       // getLocalTime()

        setTimeout(function () {
            getLocalTime()
        },1000)



    })
    function getLocalTime() {
        var time = new Date();
        var y = time.getFullYear();
        var m = time.getMonth()+1;
        var d = time.getDate();
        var h = time.getHours();
        var mm = time.getMinutes();
        var s = time.getSeconds();

        return dd = (y+'-'+add0(m)+'-'+add0(d)+'-'+add0(h)+'-'+add0(mm)+'-'+add0(s)).replace(/-/g,"")
    }


    console.log(getLocalTime())

    function add0(m){
        return m<10?'0'+m:m
    }
    var clickListener, map = new AMap.Map('container', {
        resizeEnable: true,
    });

    //输入提示
    var autoOptions = {
        input: "tipinput"
    };
    var auto = new AMap.Autocomplete(autoOptions);
    var placeSearch = new AMap.PlaceSearch({
        map: map
    });  //构造地点查询类
    AMap.event.addListener(auto, "select", select);//注册监听，当选中某条记录时会触发
    function select(e) {
        placeSearch.setCity(e.poi.adcode);
        placeSearch.search(e.poi.name);  //关键字查询查询
    }

    //bt1的click的绑定事件
    var bind = function() {
        remove(); //防止重复绑定
        clickListener = AMap.event.addListener(map, "click", function(e) {
            console.log(e.lnglat.getLng())
            new AMap.Marker({
                position: e.lnglat,
                map: map
            });
        });
    };
    //bt2的click的绑定事件
    var remove = function() {
        if (clickListener) {
            AMap.event.removeListener(clickListener);//移除事件，以绑定时返回的对象作为参数
        }
    };
    //var button1 = document.getElementById('bt1');
    //var listener1 = AMap.event.addDomListener(button1, 'click', bind);//给div绑定单击事件
    //var button2 = document.getElementById('bt2');
    //var listener2 = AMap.event.addDomListener(button2, 'click', remove);//给div绑定单击事件





    console.log(map)
    var d = '3222';
    $.ajax({
        type: 'post',
        url: 'http://221.2.74.114:18801/FireStationApi/GetStationAndAreaCountByFirePoint',
        data: JSON.stringify({ Pointlng: d, PointLat:'39.90923', Range: '322' }),
        contentType: 'application/json',
        success: function (msg) {
            debugger
            //alert(msg.state);
            if (msg.state == 1) {
                notifyStationList = msg.data.FireStationInfoView;
                areaInfoList = msg.data.AreaInfo;
                //alert(msg.data.AreaInfo[0].Number);
                //LoadStationsList(areaInfoList);
                //AddMark(notifyStationList,areaInfoList);
                console.log(notifyStationList)
            }

        }, error: function (XMLHttpRequest, textStatus, errorThrown) {

        }
    });
</script>
</html>